<template>
  <div class="app-container">
    <!-- 顶部搜索 -->
    <el-form :model="queryParams" ref="queryForm" size="small" v-show="showSearch" label-width="120px">
      <el-row :gutter="24">
        <el-col :span="6">
          <el-form-item label="产品(服务)名称:" prop="cpfwName">
            <el-input
              v-model="queryParams.cpfwName"
              placeholder="请输入产品(服务)名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="PS编号:" prop="psBh">
            <el-input
              v-model="queryParams.psBh"
              placeholder="请输入PS编号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 顶部按钮 -->
    <el-form :model="queryParams" size="mini" label-width="170px">
      <el-row :gutter="10" class="mb8" style="display: flex; justify-content: flex-end;margin-bottom: -8px">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
          >导出Excel
          </el-button>
        </el-col>
        <el-col :span="1.5" style="margin-left: auto;">
          <el-form-item label="认定计划:">
            <vxe-select @change="getList" size="mini" v-model="queryParams.nd" placeholder="请选择认定计划">
              <vxe-option v-for="item in ywJhList" :key="item.nd" :value="item.nd"
                          :label="item.jhLb"></vxe-option>
            </vxe-select>
          </el-form-item>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
    </el-form>

    <!-- 表格 -->
    <MergeTable :empty-text="'无数据'" highlight-current-row
                :merge-arr="ckMergeArr"
                v-loading="loading" :table-data="psRdList">
      <el-table-column label="年度" align="center" prop="nd"/>
      <el-table-column label="PS编号" align="center" prop="psBh"/>
      <el-table-column label="RD编号" align="center" prop="rdBh"/>
      <el-table-column label="IP编号" align="center" prop="zscqBh"/>
      <el-table-column label="产品(服务)名称" align="center" prop="cpfwName"/>
    </MergeTable>

    <!-- 分页组件 -->
    <PaginationW
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import {selectPSRDBh} from "@/api/gqgl/rdb";
import {selectYwJh} from "@/api/xtgl/ywjh";
import MergeTable from "@/components/MergeTable/index.vue";
import PaginationW from "@/components/Pagination/PaginationW.vue";

export default {
  name: "psRdBhCx",
  components: {PaginationW, MergeTable},
  //PS/RD编号查看
  data() {
    return {
      // 总条数
      total: 0,
      psRdList: [],
      ckMergeArr: ['nd', 'psBh', 'cpfwName'],
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 1000,
        psBh: null,
        nd: '2025',
        cpfwName: null,
      },
      // 显示搜索条件
      showSearch: true,
      ywJhList: null, //业务计划列表

    }
  },
  created() {
    this.getListS()
  },
  methods: {
    getList() {
      this.loading = true
      selectPSRDBh(this.queryParams).then(response => {
        this.psRdList = response.rows
        this.total = response.total;
        this.loading = false
      })
    },
    getListS() {
      this.loading = true
      let query = {
        pageNum: 1,
        pageSize: 50,
        ywSb: '平台资质',
        ywLx: '高企认定',
        zt: '启用'
      }
      selectYwJh(query).then(res => {
        this.ywJhList = res.rows;
        this.queryParams.nd = this.ywJhList[0].nd

        selectPSRDBh(this.queryParams).then(response => {
          this.psRdList = response.rows
          this.total = response.total;
          this.loading = false
        })

      })

    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('gqgl/rdb/exportPSRD', {
        ...this.queryParams
      }, `PSRD_${new Date().getTime()}.xlsx`)
    },

  }
}
</script>

<style scoped>

</style>
